<?php
if(isset($_GET['action']))
	$action=$_GET['action'];
else
	$action='login';


switch($action)
{
	
	case 'login':	
		if($_POST)
		{
			$user=new Acl_Auth_Auth($database);
			if($user->loginUser($_POST))
				header('Location: ?controller=users&action=viewUser');			
			else
			{	
				$var=Acl_Views_View::showView($_SERVER['DOCUMENT_ROOT']."/../application/views/scripts/auth/login.php");
			}
			
		}			
		else
		{ 			
			$ip=new Acl_Ips_Ip($_SERVER['REMOTE_ADDR']);				
			if($ip->getIp())
			{
				header('Location: ?controller=errors&action=blockedIp');
			}
			$var=Acl_Views_View::showView($_SERVER['DOCUMENT_ROOT']."/../application/views/scripts/auth/login.php");
		}
	break;
	case 'logout':
		session_destroy();
		header('Location: /index.php');
	break;	
	default:
		
	break;
}
echo $var;

